﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="AvailabilityBufabs.aspx.cs" Inherits="Store_AvailabilityBufabs" Title="Наличност Обкови" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
        Текущо количество на Обковите:</p>
    <p>
        Корекция на Количеството:
        <asp:Button ID="btnSubstract" runat="server" onclick="btnSubstract_Click" 
            Text="-" Width="18px" />
&nbsp;<asp:TextBox ID="txtValue" runat="server" MaxLength="5" Width="69px"></asp:TextBox>
&nbsp;<asp:Button ID="btnAdd" runat="server" onclick="btnAdd_Click" Text="+" />
&nbsp;
        <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label>
&nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="txtValue" ErrorMessage="RegularExpressionValidator" 
            ValidationExpression="^[0-9]+$">Моля въведете валидно число!</asp:RegularExpressionValidator>
    </p>
    <p>
        <asp:GridView ID="gvBufabs" runat="server" AutoGenerateColumns="False" 
            BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" 
            CellPadding="4" DataKeyNames="MaterialID" DataSourceID="sdsBufabs" 
            ForeColor="Black" GridLines="Vertical" 
            onselectedindexchanged="gvBufabs_SelectedIndexChanged">
            <FooterStyle BackColor="#CCCC99" />
            <RowStyle BackColor="#F7F7DE" />
            <Columns>
                <asp:CommandField SelectText="Избери" ShowSelectButton="True" />
                <asp:BoundField DataField="ArticleNo" HeaderText="Код" 
                    SortExpression="ArticleNo" />
                <asp:BoundField DataField="Article" HeaderText="Обков" 
                    SortExpression="Article" />
                <asp:BoundField DataField="Price" DataFormatString="{0:f}" HeaderText="Цена" 
                    SortExpression="Price" />
                <asp:TemplateField HeaderText="Количество" SortExpression="Quantity">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Quantity") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Quantity") %>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="sdsBufabs" runat="server" 
            ConnectionString="<%$ ConnectionStrings:KonturConnectionString %>" 
            SelectCommand="SELECT MaterialID, ArticleNo, Article, Price, IsBufab, Quantity FROM Materials WHERE (IsBufab = 1)">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="sdsCorrections" runat="server" 
            ConnectionString="<%$ ConnectionStrings:KonturConnectionString %>" 
            SelectCommand="UPDATE Materials SET Quantity = @quantity WHERE (MaterialID = @MaterialID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="txtValue" Name="quantity" 
                    PropertyName="Text" />
                <asp:ControlParameter ControlID="gvBufabs" Name="MaterialID" 
                    PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
</asp:Content>

